package com.example.readbook.UI.Act

import android.support.v7.widget.LinearLayoutManager
import com.example.readbook.Adapter.ReadJournalAdapter
import com.example.readbook.R
import com.example.readbook.Sql.JournalUtils
import com.example.readbook.UI.BaseUI.BaseActivity
import com.example.readbook.Utils.StringUtils
import com.example.readbook.Utils.Utils
import kotlinx.android.synthetic.main.act_read_journal.*

/**
 * Package    : com.example.readbook.UI.Act
 * ClassName  : WriteJournalEntryActivity
 * Description: $看读后感
 * Date       : 2019/3/26 13:20
 */
class ReadJournalEntryActivity : BaseActivity() {
    override fun getLayoutResID(): Int {
        return R.layout.act_read_journal
    }

    override fun initView() {
        title = "我的读后感"
        val stringExtra = intent.getStringExtra(StringUtils.BookName)
        Act_read_Recy.layoutManager = LinearLayoutManager(mActivity, LinearLayoutManager.VERTICAL, false)
        if (stringExtra.isNullOrEmpty()) {
            if (JournalUtils.getInstence(mActivity).readAllData().isNullOrEmpty()) {
                Utils.showToast("还没有读后感")
                return
            }
            Act_read_Recy.adapter = ReadJournalAdapter(mActivity, JournalUtils.getInstence(mActivity).readAllData())
        } else {
            Act_read_Recy.adapter = ReadJournalAdapter(mActivity, JournalUtils.getInstence(mActivity).readBookData(stringExtra.let { it.substring(0, it.length - 4) }))
        }
    }

    override fun initListener() {

    }

    override fun initData() {

    }
}
